<html>
  <style>
    html, body {
      margin: 0;
      padding: 0;
    }
    /* 父元素 */
    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    /* 子元素 */
    .item {
      margin: 4px;
      height: 200px;
      background-color: rgb(141, 141, 255);
      border-radius: 10px;
      text-align: center;
      line-height: 200px;
      color: #fff;
      font-size: 20px;
      font-weight: bold;
    }

  </style>
  <body>
    <div class="grid">
      <div class="item">1</div>
      <div class="item">2</div>
      <div class="item">3</div>
      <div class="item">4</div>
      <div class="item">5</div>
      <div class="item">6</div>
      <div class="item">7</div>
      <div class="item">8</div>
      <div class="item">9</div>
      <div class="item">10</div>
      <div class="item">11</div>
      <div class="item">12</div>
      <div class="item">13</div>
      <div class="item">14</div>
      <div class="item">15</div>
      <div class="item">16</div>
      <div class="item">17</div>
      <div class="item">18</div>
      <div class="item">19</div>
      <div class="item">20</div>
      <div class="item">21</div>
      <div class="item">22</div>
      <div class="item">23</div>
      <div class="item">24</div>
      <div class="item">25</div>
      <div class="item">26</div>
      <div class="item">27</div>
      <div class="item">28</div>
      <div class="item">29</div>
      <div class="item">30</div>
    </div>
  </body>
</html>